#include <signal.h>
#include <stdio.h>
#include <iostream>
using namespace std;

// 保证内存可见性！
volatile int n = 0;

void handler(int sigon)
{
    cout << "make 0 -> 1" << endl;
    n = 1;
}

int main()
{
    signal(2, handler);
    while (n == 0)
    {
        cout << "循环中" << endl;
        sleep(2);
    }
    cout << "解除循环！" << endl;
}